﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wook2_Fibonacci
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数列n的数值:");
            int number = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("数列第{0}项的值是：{1}", number, Fibonacci(number));
            Console.ReadKey();
        }
        static int Fibonacci(int number)
        {
            if (number <= 0)
                return 0;
            int a = 1;
            int b = 1;
            int c = 1;
            for (int i = 3; i <= number; i++)
            {
                c = a + b;
                a = b;
                b = c;
            }
            return c;
        }
    }
}
